#include "main.h"

void InitTim4(void)  
{  
	TIM4_ARRPreloadConfig(ENABLE);//自动重装
	TIM4_SetCounter(0x00);//计数器初值
	TIM4_SetAutoreload(0xFA);//计数器自动重装的初值
	TIM4_TimeBaseInit(TIM4_PRESCALER_64, 0xff);
  	TIM4_ClearFlag(TIM4_FLAG_UPDATE);
	TIM4_ITConfig(TIM4_IT_UPDATE, ENABLE);
	TIM4_Cmd(ENABLE);
	t4 = 0;
} 

void InitTim1(void)
{
	TIM1_DeInit();
	TIM1_TimeBaseInit(16, TIM1_COUNTERMODE_UP, 1000, 0);
	TIM1_ARRPreloadConfig(ENABLE);
	TIM1_ITConfig(TIM1_IT_UPDATE, ENABLE);
	TIM1_Cmd(ENABLE);
	t1 = 0;
}

void InitTim2(void)
{
	TIM2_DeInit();
	TIM2_TimeBaseInit( TIM2_PRESCALER_16,1000);
	TIM2_ARRPreloadConfig(ENABLE);
	TIM2_ITConfig(TIM1_IT_UPDATE, ENABLE);
	TIM2_Cmd(ENABLE);
}
